package com.schooldate.model.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.schooldate.annotation.JsonIncludeField;
import com.schooldate.base.BaseVo;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.schema.JsonSerializableSchema;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 用户基本信息类
 * Created by L先森 on 2015/3/8.
 */
@Entity
@SuppressWarnings("all")
public class UserInfo extends BaseVo{

    @Id
    @Column(name = "id",length = 10)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Column
    private Long userId;

    @Column(length = 2)
    private String  gender;

//    是否牵手
    @Column(length = 2)
    private Boolean isHand;

    //    是否单身
    @Column(length = 2)
    private Boolean isSingle;
    @Column
    private  String hobbies;
    @Column
    private String signature;
    @Column
    private String birthday;
    @Column(length = 100)
    private String trueName;
    @Column(length = 100)
    private String email;
    @Column(length = 100)
    private String nickName;
    @Column(length = 100)
    private String password;
    @Column(length = 100)
    private String schoolNum;
    @Column(length = 100)
    private String schoolPwd;
    @Column(length = 100)
    private String startSchoolTime;
    @Column
    private String devicetoken;
    @Column
    private Long reciFlower = 0L;
    @Column
    private Long flowerSendLimit = 10L;
    @Column
    private Long flowerSendLeft = 10L;
//    今天是否登录
    private Boolean isLoginToday = false;
//    全部图片
    @Column
    private String imagesPath;
//    头像
    private String headImagePath;
//   注册时间
    @Column(length = 100)
    private String regTime;

    @Transient
    private Set<String> imagePaths = new HashSet<String>();

    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "ASideId")
    private Set<HandMessage> ASides;

    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "BSideId")
    private Set<HandMessage> BSides;

    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "userInfoId")
    private Set<UserFlower> userFlowers;


    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "userInfoId")
    private Set<HeadImage> headImages;

    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "userInfoId")
    private Set<MessageBoard> messageBoards;

    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "userInfoId")
    private Set<MessageBoardReply> messageBoardReplies = new HashSet<MessageBoardReply>();

    @OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinColumn(name = "userInfoId")
    private Set<ExamSource> examSources = new HashSet<ExamSource>();

    @ManyToOne(targetEntity = School.class,cascade = CascadeType.MERGE)
    @JoinColumn(name = "schoolInfoId")
    private School school;

    @ManyToOne(targetEntity = Department.class,cascade = CascadeType.MERGE)
    @JoinColumn(name = "departmentId")
    private Department department;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @JsonIncludeField(namespace = {"clickMe.do","userInfo","index","messageBoards.do","chickIntoTheMessag.do"})
    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public Boolean getIsHand() {
        return isHand;
    }

    public void setIsHand(Boolean isHand) {
        this.isHand = isHand;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public Boolean getIsSingle() {
        return isSingle;
    }

    public void setIsSingle(Boolean isSingle) {
        this.isSingle = isSingle;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getTrueName() {
        return trueName;
    }

    public void setTrueName(String trueName) {
        this.trueName = trueName;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @JsonIncludeField(namespace = {"userInfo","index","messageBoardId","messageBoards.do","chickIntoTheMessag.do"})
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getSchoolNum() {
        return schoolNum;
    }

    public void setSchoolNum(String schoolNum) {
        this.schoolNum = schoolNum;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getSchoolPwd() {
        return schoolPwd;
    }

    public void setSchoolPwd(String schoolPwd) {
        this.schoolPwd = schoolPwd;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getStartSchoolTime() {
        return startSchoolTime;
    }

    public void setStartSchoolTime(String startSchoolTime) {
        this.startSchoolTime = startSchoolTime;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getRegTime() {
        return regTime;
    }

    public void setRegTime(String regTime) {
        this.regTime = regTime;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public School getSchool() {
        return school;
    }


    public void setSchool(School school) {
        this.school = school;
    }

    public Set<UserFlower> getUserFlowers() {
        return userFlowers;
    }

    public void setUserFlowers(Set<UserFlower> userFlowers) {
        this.userFlowers = userFlowers;
    }

    public Set<HeadImage> getHeadImages() {
        return headImages;
    }

    public void setHeadImages(Set<HeadImage> headImages) {
        this.headImages = headImages;
    }

    public Set<MessageBoard> getMessageBoards() {
        return messageBoards;
    }

    public void setMessageBoards(Set<MessageBoard> messageBoards) {
        this.messageBoards = messageBoards;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getImagesPath() {
        return imagesPath;
    }

    public void setImagesPath(String imagesPath) {
        this.imagesPath = imagesPath;
    }

    @JsonIncludeField(namespace = {"userInfo","index","chickIntoTheMessag.do","messageBoards.do"})
    public String getHeadImagePath() {
        return headImagePath;
    }

    public void setHeadImagePath(String headImagePath) {
        this.headImagePath = headImagePath;
    }

    public Set<HandMessage> getASides() {
        return ASides;
    }

    public void setASides(Set<HandMessage> ASides) {
        this.ASides = ASides;
    }

    public Set<HandMessage> getBSides() {
        return BSides;
    }

    public void setBSides(Set<HandMessage> BSides) {
        this.BSides = BSides;
    }

    @JsonIncludeField(namespace = {"userInfo","index"})
    public Long getReciFlower() {
        return reciFlower;
    }

    public void setReciFlower(Long reciFlower) {
        this.reciFlower = reciFlower;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public Long getFlowerSendLimit() {
        return flowerSendLimit;
    }

    public void setFlowerSendLimit(Long flowerSendLimit) {
        this.flowerSendLimit = flowerSendLimit;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public Long getFlowerSendLeft() {
        return flowerSendLeft;
    }

    public void setFlowerSendLeft(Long flowerSendLeft) {
        this.flowerSendLeft = flowerSendLeft;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public Boolean getIsLoginToday() {
        return isLoginToday;
    }

    public void setIsLoginToday(Boolean isLoginToday) {
        this.isLoginToday = isLoginToday;
    }

    public Set<MessageBoardReply> getMessageBoardReplies() {
        return messageBoardReplies;
    }

    public void setMessageBoardReplies(Set<MessageBoardReply> messageBoardReplies) {
        this.messageBoardReplies = messageBoardReplies;
    }

    @JsonIncludeField(namespace = {"userInfo","index","messageBoards.do","chickIntoTheMessag.do"})
    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getHobbies() {
        return hobbies;
    }

    public void setHobbies(String hobbies) {
        this.hobbies = hobbies;
    }

    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }

    public Set<String> getImagePaths() {
        String path = this.getImagesPath();
        if (path==null)
            return null;
        String[] paths = path.split(",");
        for (String str:paths){
            imagePaths.add(str);
        }
        return imagePaths;
    }

    public String getDevicetoken() {
        return devicetoken;
    }

    public void setDevicetoken(String devicetoken) {
        this.devicetoken = devicetoken;
    }

    public void setImagePaths(Set<String> imagePaths) {
        this.imagePaths = imagePaths;
    }

    public Set<ExamSource> getExamSources() {
        return examSources;
    }

    public void setExamSources(Set<ExamSource> examSources) {
        this.examSources = examSources;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "id=" + id +
                ", gender='" + gender + '\'' +
                ", isHand=" + isHand +
                ", isSingle=" + isSingle +
                ", trueName='" + trueName + '\'' +
                ", email='" + email + '\'' +
                ", nickName='" + nickName + '\'' +
                ", password='" + password + '\'' +
                ", schoolNum='" + schoolNum + '\'' +
                ", schoolPwd='" + schoolPwd + '\'' +
                ", startSchoolTime='" + startSchoolTime + '\'' +
                ", reciFlower=" + reciFlower +
                ", flowerSendLimit=" + flowerSendLimit +
                ", flowerSendLeft=" + flowerSendLeft +
                ", isLoginToday=" + isLoginToday +
                ", imagesPath='" + imagesPath + '\'' +
                ", headImagePath='" + headImagePath + '\'' +
                ", regTime='" + regTime + '\'' +
                ", ASides=" + ASides +
                ", BSides=" + BSides +
                ", userFlowers=" + userFlowers +
                ", headImages=" + headImages +
                ", messageBoards=" + messageBoards +
                ", school=" + school +
                '}';
    }

}
